<script src="../../../../public/static/common/js/jquery.2.1.1.min.js"></script>{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('APPID')}</label>
            <div class="layui-input-4">
                <input type="text" name="APPID" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('APPID')}" value="{$wchat_config.APPID}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Appsecret')}</label>
            <div class="layui-input-4">
                <input type="text" name="APPSECRET" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('APPSECRET')}" value="{$wchat_config.APPSECRET}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                APPID以及APPSECRET来自于您的公众号信息。
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">MCHID</label>
            <div class="layui-input-4">
                <input type="text" name="MCHID" lay-verify="required" placeholder="输入商户号" class="layui-input" value="{$wchat_config.MCHID}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">KEY</label>
            <div class="layui-input-4">
                <input type="text" name="KEY" lay-verify="required" placeholder="输入支付密钥" class="layui-input" value="{$wchat_config.KEY}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                MCHID以及KEY来源于微信支付平台信息。
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}

<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = layui.layer, $ = layui.jquery;
        form.on('submit(submit)', function (data) {
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            $.post("{:url('setWxPayConfig')}",data.field,function (res) {
                layer.close(loading);
                if(res.code > 0){
                    layer.msg(res.msg,{icon: 1, time: 1000},function(){
                        location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{icon: 2, time: 1000});
                }
            });
        });

    })
</script>
</body>
</html>